use super::type_schema::TypeSchema;
use super::type_derive::DerivationTransform;
use serde_json::Value as JSONValue;

pub trait DataTrait {
    /// 验证Data是否满足的特定的TypeSchema
    fn qualify(&self, ts: &TypeSchema) -> bool;
    /// 交出所有权，序列化为不可重建JSON
    fn as_json_less(self) -> JSONValue;
    /// 交出所有权，序列化为可重建JSON
    fn as_json_full(self) -> JSONValue;
    /// 不交出所有权，序列化为不可重建JSON
    fn to_json_less(&self) -> JSONValue;
    /// 不交出所有权，序列化为可重建JSON
    fn to_json_full(&self) -> JSONValue;
    /// 从JSONLess反序列化
    fn from_json_less(data: JSONValue, ts: &TypeSchema) -> Self;
    /// 从JSONFull反序列化
    fn from_json_full(data: JSONValue) -> Self;
    /// 用于debug
    fn to_string(&self) -> String;
}

/// 移交出所有权供解构处理，获得三个参数的所有权。需要同Data一起实现
fn destruct_apply(data: DataTraitImpl, tr: DerivationTransform, func: TaskFunc) -> O_DataType { todo!() }

/// 假设的实现DataTrait的类型
struct DataTraitImpl;

type I_DataType = DataTraitImpl;
type O_DataType = DataTraitImpl;
type TaskFunc = fn(I_DataType) -> O_DataType;